<?php
// 开启会话
session_start();

// 初始化游戏数据
if (!isset($_SESSION['game'])) {
    $_SESSION['game'] = [
        'status' => '清华特招学生',
        'money' => 0,
        'experience' => 0,
        'stage' => 1
    ];
}

// 处理玩家选择
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['choice'])) {
    $choice = $_POST['choice'];
    $game = &$_SESSION['game'];

    switch ($game['stage']) {
        case 1: // 毕业后选择
            if ($choice === '创业') {
                $game['status'] = '创业者';
                $game['money'] -= 50000; // 创业初始成本
                $game['experience'] += 20;
                $message = "你选择了创业，投入了 50000 元启动资金，获得了 20 点经验值。";
            } elseif ($choice === '求职') {
                $game['status'] = '职场新人';
                $game['money'] += 3000; // 首月工资
                $game['experience'] += 10;
                $message = "你选择了求职，获得了 3000 元工资，获得了 10 点经验值。";
            } elseif ($choice === '出国留学') {
                $game['status'] = '留学生';
                $game['money'] -= 200000; // 留学费用
                $game['experience'] += 50;
                $message = "你选择了出国留学，花费了 200000 元学费，获得了 50 点经验值。";
                $game['stage'] = 2;
            }
            break;
        case 2: // 留学回国后选择
            if ($choice === '一边创业一边供职') {
                $game['status'] = '创业者兼职场人士';
                $game['money'] += 5000; // 供职收入
                $game['money'] -= 30000; // 创业追加成本
                $game['experience'] += 30;
                $message = "你选择了一边创业一边供职，获得了 5000 元供职收入，投入 30000 元创业资金，获得了 30 点经验值。";
                $game['stage'] = 3;
            }
            break;
    }
}
?>

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>大学生毕业求职创业模拟游戏</title>
    <style>
        body {
            font-family: "Microsoft YaHei", sans-serif;
            background-color: #f4f4f4;
            padding: 20px;
        }

        h1 {
            text-align: center;
            color: #333;
        }

        p {
            margin-bottom: 10px;
        }

        form {
            background-color: #fff;
            padding: 20px;
            border-radius: 5px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
        }

        button {
            padding: 10px 20px;
            background-color: #007BFF;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        .message {
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 5px;
        }

        .success {
            background-color: #d4edda;
            color: #155724;
        }

        .error {
            background-color: #f8d7da;
            color: #721c24;
        }
    </style>
</head>

<body>
    <h1>大学生毕业求职创业模拟游戏</h1>
    <p>当前状态: <?php echo $_SESSION['game']['status']; ?></p>
    <p>当前资金: <?php echo $_SESSION['game']['money']; ?> 元</p>
    <p>当前经验值: <?php echo $_SESSION['game']['experience']; ?></p>

    <?php if (isset($message)): ?>
        <div class="message <?php echo strpos($message, '成功')!== false? 'success' : 'error'; ?>">
            <?php echo $message; ?>
        </div>
    <?php endif; ?>

    <?php if ($_SESSION['game']['stage'] == 1): ?>
        <form method="post">
            <button type="submit" name="choice" value="创业">创业</button>
            <button type="submit" name="choice" value="求职">求职</button>
            <button type="submit" name="choice" value="出国留学">出国留学</button>
        </form>
    <?php elseif ($_SESSION['game']['stage'] == 2): ?>
        <form method="post">
            <button type="submit" name="choice" value="一边创业一边供职">一边创业一边供职</button>
        </form>
    <?php elseif ($_SESSION['game']['stage'] == 3): ?>
        <p>你已经功成名就，游戏结束！</p>
    <?php endif; ?>
</body>

</html>